public without sharing class TaskTrackingImportHandler {
	//新建的时候自动计算税率
	public static void  calcTax(List<TaskTrackingImport__c> details ){


		Id rtId = Utils.getRecordTypeIdByDevNameAndObjName('ConfirmationForm', 'TaskTrackingImport__c');
		Map<String,Decimal>  taxMap = new Map<String,Decimal>();
		Map<String,Boolean> accMap  = new Map<String,Boolean>();
		for (TaskTrackingImport__c tti : details ) {

			if(tti.RecordTypeId != rtId)continue;

			if(tti.Account__c == null )tti.addError('开票客户不能为空!');
			if(tti.OwnerCompany__c == null )tti.addError('归属子公司不能为空!');
			if(tti.RegentBrand__c == null )tti.addError('试剂追踪品牌不能为空!');

			//taxMap.put(tti.Account__c+tti.Company__c+tti.RegentBrand__c, null);
			accMap.put(tti.Account__c, false);

		}
		
		for (Account acc : [select Id,System__c from Account where Id in: accMap.keySet() ]) {
			
			accMap.put(acc.Id , acc.System__c != null );
		}

		for ( TaskTrackingImport__c tti : details ) {
			
			tti.Tax__c = calcTax(accMap.get(tti.Account__c),tti.RegentBrand__c,tti.OwnerCompany__c);
		}




	}


	public static Decimal calcTax(Boolean isTrid ,String brand ,String company ){

		if(brand == '非迈克') return 13.0;
		if( !MaccuraBrandUtil.maccura.contains(brand) )return 13.0;
		//是否简易增收 
		Set<String> simpleSets  = new Set<String>{'迈克生物','迈克实业','重庆征途','广东迈克','山西迈克','中区','东区','南区','西区','北区'};
		Boolean isSimple  = simpleSets.contains(company);
		if(isSimple) return 5.0;
		return isTrid ? 9.0 : 12.0;

	}
    
}